<?php defined('SYSPATH') or die('No direct script access.');
require ('application/classes/dao/base.php');
require ('application/classes/api/get.php');
class Controller_login extends Controller {


	public function action_login(){
		$parm['type'] = 22;
		$result = rpcCall('productpageset.getLoginImg',$parm);

		echo View::factory('web/login')->set('data',$result);
	}
	public function action_userLogin(){

		$parm = post($this->request);

		$result = null;
		$msg = null;
		try{
			if(!isset($parm['phone']) ||($parm['phone'])==""){
				echo "手机号不能为空";
				exit;
			}
			if(!isset($parm['password']) ||($parm['password'])==""){
				echo "密码不能为空";
				exit;
			}
			$result = rpcCall('user.userlogin',$parm);
//			echo print_r($result);
			if($result['status']){

				setUserSession('user',$result['user']);
				$get = new get();
				$get->setCache('user'.$result['user']['id'],$result['user']);
				$result['user']='';
			}




		}catch (Exception $e){
			$result['msg'] = '登录失败';
			$result['status'] = true;

		}finally{
			echo json_encode($result);
		}


	}

}
